//
//  MainHeaderScrollView.m
//  WZYInteriorDesign
//
//  Created by lanou on 15/12/17.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "MainHeaderScrollView.h"
#import "UIImageView+AFNetworking.h"
#import "TapImageView.h"
@implementation MainHeaderScrollView

- (instancetype)initWithFrame:(CGRect)frame target:(id)target action:(SEL)action imageArray:(NSArray *)imageArray timer:(NSTimeInterval)timer selectro:(SEL)selector{
    
    self = [super initWithFrame:frame];
    if (self) {
        NSMutableArray *insterImageArray = [NSMutableArray arrayWithArray:imageArray];
        
        [insterImageArray insertObject:imageArray.lastObject atIndex:0];
        
        [insterImageArray insertObject:imageArray.firstObject atIndex:insterImageArray.count];
        
        self.contentSize = CGSizeMake(insterImageArray.count * kWidth, 0);
        
        self.bounces = NO;
        self.delegate = target;
        self.pagingEnabled = YES;
        self.contentOffset = CGPointMake(kWidth, 0);
        self.showsHorizontalScrollIndicator = NO;
        
        for (int i = 0; i < insterImageArray.count; i ++) {
            TapImageView *tapImage = [[TapImageView alloc] initWithFrame:CGRectMake(i * kWidth, 0, kWidth, self.bounds.size.height) target:target action:action];
            
            [tapImage setImageWithURL:[NSURL URLWithString:insterImageArray[i]]];
            
            [self addSubview:tapImage];
        }
        [NSTimer scheduledTimerWithTimeInterval:timer target:target selector:selector userInfo:nil repeats:YES];
        
    }
    return self;
}















/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
